<template>
	<uni-nav-bar v-if="!sheep.$store('app').isWxBrowser" title="个人中心" fixed height="100rpx" />
	<view class="user-container">
		<view class="top">
			<view class="user-info">
				<img class="user-avatar" :src="userInfo.avatar" />
				<view class="user-show-intro">
					<view class="user-name">{{ userInfo.name }} </view>
					<view class="show-tel"> {{ showMobile(userInfo.phone) }}</view>
				</view>
			</view>
		</view>
		<view class="menu-area">
			<view class="menu-list">
				<view class="sample-record list-detial" @click="goToPrintRecord">
					<img class="image" src="../../static/common/printRecord.png" />
					<view class="show-title"> 我的打样记录</view>
				</view>
				<view class="sample-record list-detial" @click="goToCollection">
					<img class="image" src="../../static/common/collection.png" />
					<view class="show-title"> 我的收藏</view>
				</view>
			</view>
			<view class="short-menu">
				<view class="item-link" @click="goToCustomerService">
					<view class="left-title">
						<img src="../../static/common/call.png" />
						<view class="text"> 联系客服 </view>
					</view>
					<img src="../../static/common/arrow.png" />
				</view>
				<view class="item-link" @click="goToPrivacyAgreement">
					<view class="left-title">
						<img src="../../static/common/agreement.png" />
						<view class="text"> 隐私协议 </view>
					</view>
					<img src="../../static/common/arrow.png" />
				</view>
				<view class="item-link" @click="goToServiceAgreement">
					<view class="left-title">
						<img src="../../static/common/sever.png" />
						<view class="text"> 服务协议 </view>
					</view>
					<img src="../../static/common/arrow.png" />
				</view>
			</view>
		</view>
		<view class="login-button" @click="outLogin"> 退出登录</view>
	</view>
	<!-- 权限弹窗 -->
	<f-auth-modal v-if="sheep.$store('user').authModal"></f-auth-modal>
</template>

<script setup>
	import { computed, ref } from 'vue';
	import { onShow, onPageScroll } from '@dcloudio/uni-app';
	import sheep from '@/sheep';

	onShow(() => {});
	onPageScroll(() => {});

	const userInfo = computed(() => JSON.parse(JSON.stringify(sheep.$store('user').userInfo)));
	console.log('userInfo===', userInfo);

	const showMobile = (val) => {
		if (val) {
			return val.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
		} else {
			return '';
		}
	};
	const outLogin = () => {
		sheep.$store('user').logout(true);
		sheep.$router.go('/pages/index/login');
		console.log('退出登录====>');
	};
	const goToPrintRecord = () => {
		console.log('跳转到我的打样记录====>');
		sheep.$router.go('/pages/index/printRecord');
	};
	const goToCollection = () => {
		console.log('跳转到我的收藏====>');
		sheep.$router.go('/pages/index/collection');
	};
	const goToCustomerService = () => {
		console.log('跳转到联系客服====>');
		sheep.$router.go('/pages/index/chat');
	};
	const goToServiceAgreement = () => {
		console.log('跳转到服务协议====>');
		sheep.$router.go('/pages/index/serviceAgreement');
	};
	const goToPrivacyAgreement = () => {
		console.log('跳转隐私协议====>');
		sheep.$router.go('/pages/index/privacyAgreement');
	};
</script>

<style scoped lang="scss">
	.user-container {
		width: 100%;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: cener;
		overflow: hidden;
		.top {
			width: 100%;
			height: 500rpx;
			background-image: url('../../static/common/mineBg.png');
			background-repeat: no-repeat;
			background-size: 100%;
			overflow: hidden;
			object-fit: cover;
			.user-info {
				max-width: 330rpx;
				height: 120rpx;
				margin: 64rpx 0 0 32rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.user-avatar {
					width: 120rpx;
					height: 120rpx;
					border-radius: 50%;
				}

				.user-show-intro {
					height: 88rpx;
					display: flex;
					flex-direction: column;
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #ffffff;
					line-height: 44rpx;
					text-align: left;
					font-style: normal;
					align-items: flex-start;
					width: 100%;
					padding-left: 10px;
				}
			}
		}

		.menu-area {
			width: 684rpx;
			margin: 0 32rpx 64rpx 32rpx;
			position: relative;
			top: -130px;

			.menu-list {
				height: 160rpx;
				background: #ffffff;
				box-shadow: 0px 30rpx 30rpx -20rpx rgba(18, 24, 26, 0.1);
				border-radius: 16rpx;
				padding: 16rpx 0;
				display: flex;

				.sample-record {
					flex: 1;
					height: 100%;
					border-right: 2rpx solid #e7e7e8;
				}

				.my-collection {
					flex: 1;
					height: 100%;
				}

				.list-detial {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-evenly;

					.image {
						width: 60rpx;
						height: 60rpx;
						object-fit: contain;
					}

					.show-title {
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 26rpx;
						color: #666666;
						line-height: 36rpx;
						text-align: right;
						font-style: normal;
					}
				}
			}

			.short-menu {
				margin-top: 20rpx;
				.item-link {
					height: 89rpx;
					border-bottom: 2rpx solid #e7e7e8;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.left-title {
						width: 168rpx;
						height: 42rpx;
						display: flex;
						align-items: center;
						justify-content: space-between;

						img {
							width: 40rpx;
							height: 40rpx;
						}

						.text {
							font-family: PingFangSC, PingFang SC;
							font-weight: 500;
							font-size: 28rpx;
							line-height: 40rpx;
							text-align: left;
							font-style: normal;
						}
					}

					img {
						width: 40rpx;
						height: 40rpx;
					}
				}

				.item-link:last-child {
					border: none;
				}
			}
		}

		.login-button {
			width: 310rpx;
			height: 88rpx;
			margin-top: 18rpx;
			border-radius: 60rpx;
			border: 2rpx solid #111111;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #111111;
			line-height: 40rpx;
			font-style: normal;
			display: flex;
			justify-content: center;
			align-items: center;
			position: absolute;
			// top: 1052rpx;
			bottom: 0;
			left: 50%;
			transform: translate(-50%, -50%);
		}
	}
	html,
	body {
		background-color: #fff;
	}
</style>
